import { ClubDao } from "../../hall_server/dao/ClubDao";
import { ClubModel } from "../../hall_server/model/ClubModel";
import { JhaoProto } from "../../src/lib/net/protobuf/jhaoproto";
import { UserDao } from "../dao/UserDao";
import { UserEntity } from "../entity/UserEntity";

export class UserModel {

    public userid: number
    public account: string;
    public nick_name: string;
    public headimg: string;
    public sex: number;

    public coins:number = 0
    public diamond:number = 0
    public room_id:number = 0

    public json2Model(data: UserEntity) {
        this.userid = data.userid
        this.account = data.account
        this.nick_name = data.nick_name
        this.sex = data.sex
        this.headimg = data.headimgurl
    }

    public resource2Model(data:object){
        this.coins = data["coins"]
        this.diamond = data["diamond"]
    }

    public static db2Model(data: UserEntity) {
        let model: UserModel = new UserModel()
        model.json2Model(data)
        return model
    }

    public destroy() {
    }

    public model2proto() {
        let userinfo:JhaoProto.IUserInfo = {
            userId:this.userid,
            userName:this.nick_name,
            userPhoto:this.headimg,
            sex:this.sex,
            coins:this.coins,
            diamond:this.diamond
        }
        return userinfo
    }

}